<?php
/*echo $_REQUEST['pro_id'];
echo $_REQUEST['project_name'];
echo $_REQUEST['project_manager'];
echo $_REQUEST['pro_description'];
echo $_REQUEST['start_date'];
echo $_REQUEST['complete_date'];
echo $_REQUEST['pro_status'];*/
include "../../operations/connection_ajax.php";
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
	$lang = $_SESSION['lang'];		
	if (empty($lang) || $lang == "EN") {
		$value = "../../value/value_en.php";
	} else if($lang == "VN") {
		$value = "../../value/value_vn.php";
	}
	else {
		$value = "../../value/value_kr.php";
	}
	
	include($value);
	
if ( !isset($_REQUEST['pages'] ))
	{
    	$page = 1 ;
	}else{
		$page = $_REQUEST['pages'] ;
} 
	$sortstring = ""; 
	if ($_REQUEST['flags']=='fullname') {
		if ($_REQUEST['orderby']==SORT_ASC){
			$sortstring = " order by FullName DESC ";  
		}else{
			$sortstring = " order by FullName ASC "; 
		}
		
	}else 
	if ($_REQUEST['flags']=='position') {
		if ($_REQUEST['orderby']==SORT_ASC){
			$sortstring = " order by Position DESC ";  
		}else{
			$sortstring = " order by Position ASC "; 
		}
	}
	
	
	$_SESSION['searchstring'] = $sortstring;

	$rows_per_page = 10;
	$page_start = ( $page - 1 ) * $rows_per_page; 
	$page_end = $page * $rows_per_page;
	
	
$listemployeePage = mysql_query("SELECT em.IDEmployee FROM employee em left JOIN department_lang dpl
	 on em.IDDepartment = dpl.IDDepartment where em.State = 1 and dpl.LangID='".$lang."'".$sortstring);
	
$listemployee = mysql_query("SELECT em.IDEmployee,em.UserName, em.FullName ,dpl.DepartmentName, em.Position ,em.Sex, em.IDDepartment FROM employee em left JOIN department_lang dpl
 on em.IDDepartment = dpl.IDDepartment where em.State = 1 and dpl.LangID='".$lang."' ".$sortstring." limit ".$page_start.",".$rows_per_page);

$number_of_page_employees = ceil ( mysql_num_rows( $listemployeePage ) / $rows_per_page );


               unset($_SESSION['lstemps']);
	                $temp_lstemps = array();
	                while ($row=mysql_fetch_array($listemployee)){ 
	                	array_push($temp_lstemps, array($row[IDEmployee],$row[UserName],$row[FullName],$row[DepartmentName],$row[Position],$row[Sex],$row[IDDepartment]));
	                	
					?>
	                <tr>
		                <td align="center" class="FullName"><?=$row[FullName]?></td>
		                <td align="center"><?=$row[DepartmentName]?></td>
		                <td align="center" class="IDEmployee"><?=$row[Position]?><input type="hidden" value="<?=$row[IDEmployee]?>"/></td>
		                <td align="left">
		                	<span class="buttonProject" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" onclick="addTester(this)" style="padding: 5px; border:1px solid #999"><?=$_addtester?></span>
		                	|
		                	<span class="buttonProject" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" onclick="addCoder(this)" style="padding: 5px; border:1px solid #999"><?=$_addcoder?> </span>
		                	<input type="hidden" value="<?=$row[UserName]?>"/>
		                </td>
	                </tr>
	                <?php }
	                $_SESSION['lstemps'] = $temp_lstemps;
	                $temp_lstemps = null;
	                ?>
	                <tr class="trfoot">
	                    	<td class="rf-dt-ftr-c" scope="colgroup" colspan="6">
	                        	<div style="text-align: center; width: 100%">
	                            	<span class="rf-ds">
															
															<?php if ( $number_of_page_employees > 1 ) 
															{ 
																if ($page==1)
																	$p=2;
																else if ($page==$number_of_page_employees)
																	$p=$number_of_page_employees-1;
																else $p=$page;
																if($page!=1){?>
																	<a onclick="paging(1,'#listEmps')" ><span class='button_next'><?php echo "<<<";?></span> </a>
																	<a onclick="paging(<?=($page-1)?>,'#listEmps')" ><span class='button_next'><?php echo "<<";?></span> </a>
																<?php  }
																else{
																	echo "<span class='button_next'><<<</span>"; 
																	echo "<span class='button_next'><<</span>";
																}
																for ( $i = $p-1; $i <= $p+1; $i++ ) {	
																		if ($i<=$number_of_page_employees && $i>0)
																		
																			if ($i==$page){
																				echo "<span class='button_next' style='color: #000'><i>".$i."</i></span>"; 
																			}else{
																			?>
																				<a onclick="paging(<?=$i?>,'#listEmps')" ><span class="button_next">
																				<?php 
																				echo $i;
																				?>
																				</span> </a>
																			<?php 
																			}
																		?>
																	
																<?php 
																		}
																	
																	if($page!=$number_of_page_employees){ ?>
																		<a onclick="paging(<?=($page+1)?>,'#listEmps')"><span class='button_next'><?php echo ">>";?></span> </a>
																		<a onclick="paging(<?=($number_of_page_employees)?>,'#listEmps')" ><span class='button_next'><?php echo ">>>";?></span> </a>
																	<?php }
																	else{
																		echo "<span class='button_next'>>></span> ";
																		echo "<span class='button_next'>>>></span> ";
																	}
																}
															
																
																?>
																													
														</span>
														</div>
														</td>
	                    </tr>

<?php 
mysql_close($connection_ajax);
?>